package com.ruoyi.pay.service;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.pay.domain.CreateOrderReq;
import com.ruoyi.pay.domain.QueryOrderReq;
import com.ruoyi.pay.domain.WxOrder;
import com.wechat.pay.java.service.partnerpayments.nativepay.model.Transaction;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

public interface PayService {

    /***
     * 预支付订单
     * @param req
     * @return
     */
     AjaxResult createOrder(CreateOrderReq req) throws Exception;

    /**
     * 微信支付回调通知
     * @param request
     * @return
     * @throws Exception
     */
    Map<String,String> payNotify(HttpServletRequest request) throws Exception;

    /** 根据商户订单号查询订单 outTradeNo
     * @param req
     * @return
     */
     AjaxResult queryOrderByOrderNo(QueryOrderReq req);

    /** 根据支付订单号查询订单 paymentNo
     * @param req
     * @return
     * */
     AjaxResult queryOrderByPaymentNo(QueryOrderReq req);

    /** 微信申请退款
     * @param outTradeNo 商户订单号
     * @param totalAmount
     * @return
     */
     AjaxResult createRefund(String outTradeNo, Long totalAmount);

    /** 微信申请退款
     * @param outTradeNo 商户订单号
     * @param totalAmount 退款金额，单位分
     * @return*/
     AjaxResult createRefund(String outTradeNo, Long totalAmount, String outRefundNo);

    /** 微信退款回调
     * @param request
     * @throws Exception*/
     void refundNotify(HttpServletRequest request) throws Exception;


     /** 支付成功后入库
      * @param orderOld
      * @param transaction
      * @throws Exception*/
     void success(WxOrder orderOld, Transaction transaction);

     /** 查询id
      * @param outTradeNo
      * @throws Exception*/
     WxOrder selectByOrder(String outTradeNo);
 }
